{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## PolymerConformation and CombinatorialConformation\n", "\n", "BioCRNpyler contains a number of specialized classes to represent conformations (secondary structures) of Polymers and the reactions involved in producing these conformations. This notebook provides an introduction to these features and examples of how to use them.\n", "\n", "__PolymerConformation__ is a Species that represents 1 or more OrderedPolymerSpecies with a set of complexes describing how these OrderedPolymerSpecies are in contact.\n", "\n", "__CombinatorialConformation__ is a Component which wraps around PolymerConformations (containing just a single Polymer) and enumerates binding and unbinding reactions in order to form different Conformations, similarly to the CombinatorialComplex Component.\n", "\n", "__CombinatorialConformationPromoter__ is a combination of CombinatorialConformation and a Promoter which can be used to represent the dynamic structure DNA in settings coupled to transcription." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Example 1: PolymerConformations\n", "\n", "In this example, we will consider an OrderedPolymerSpecies AABC and build a PolymerConformation with two internal Complexes: AB and ACS. Here, S is an external species not part of the polymer. PolymerConformations easiest to build iteratively, one Complex at a time." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "pc is an emtpy PolymerConformation, which represents as an OrderedPolymerSpecies: ordered_polymer_A_A_B_C_\n", "pc contains no complexes: []\n", "pc contains one polymer: [ordered_polymer_A_A_B_C_]\n", "\n", "c1: complex_A_B_\n", "pc1: conformation__ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B__\n", "pc1 contains one complex: [complex_A_B_]\n", "pc1 contains one polymer: [ordered_polymer_A_A_B_C_]\n", "\n", "c2: complex_A_C_S_\n", "pc2: conformation__ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B__p0l1p0l3n_complex_A_C_S__\n", "pc2 contains two complexes: [complex_A_B_, complex_A_C_S_]\n", "pc2 contains one polymer: [ordered_polymer_A_A_B_C_]\n", "\n", "c3: complex_A_C_S_\n", "pc3 conformation__ordered_polymer_A_A_B_C__ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B__p0l1p1l3n_complex_A_C_S__\n", "pc3 contains two complexes: [complex_A_B_, complex_A_C_S_]\n", "pc3 contains two polymers: [ordered_polymer_A_A_B_C_, ordered_polymer_A_A_B_C_]\n" ] } ], "source": [ "from biocrnpyler.core import Species\n", "from biocrnpyler.components import PolymerConformation, Complex\n", "\n", "A, B, C, S = Species(\"A\"), Species(\"B\"), Species(\"C\"), Species(\"S\")\n", "\n", "#First Create an PolymerConformation wrapped around a single string of Monomers (e.g. a Polymer)\n", "#This PolymerConformation has no internal complexes\n", "pc = PolymerConformation(polymer = [A, A, B, C])\n", "print(\"pc is an emtpy PolymerConformation, which represents as an OrderedPolymerSpecies:\", pc)\n", "print(\"pc contains no complexes:\", pc.complexes)\n", "print(\"pc contains one polymer:\", pc.polymers)\n", "\n", "#Make a polymer conformation indirectly using the Complex function to join the monomers inside a Polymer\n", "c1 = Complex([pc.polymers[0][0], pc.polymers[0][2]]) #Form a Complex A:B\n", "print('\\nc1:', c1)\n", "pc1 = c1.parent #This complex has a parent which is a PolymerConformation\n", "print('pc1:', pc1)\n", "print(\"pc1 contains one complex:\", pc1.complexes)\n", "print(\"pc1 contains one polymer:\", pc1.polymers)\n", "\n", "#Next, take the polymer inside the new conformation and add a new contact which now includes an additional species S\n", "#Notice how pc1's internal polymer is used, this way the same polymer has two contacts\n", "c2 = Complex([pc1.polymers[0][1], pc1.polymers[0][3], S])\n", "print(\"\\nc2:\", c2)\n", "pc2 = c2.parent\n", "print(\"pc2:\", pc2)\n", "print(\"pc2 contains two complexes:\", pc2.complexes)\n", "print(\"pc2 contains one polymer:\", pc2.polymers)\n", "\n", "#Now we produce a complex between two different polymers\n", "#Notice that pc1 is used for one polymer and p is used for the other polymer.\n", "#This represents the binding of two seperate polymers\n", "c3 = Complex([pc1.polymers[0][1], pc.polymers[0][3], S])\n", "print(\"\\nc3:\", c3)\n", "pc3 = c3.parent\n", "print(\"pc3\", pc3)\n", "print(\"pc3 contains two complexes:\", pc3.complexes)\n", "print(\"pc3 contains two polymers:\", pc3.polymers)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Example 2: CombinatorialConformation\n", "\n", "CombinatorialConformation is a Component which produces species and reactions allowing for the binding and unbinding of complexes in a PolymerConformation with a single internal polymer. This component transforms a set of initial_states to a set of final_states via a set of intermediate_states. Abstractly, this can be written\n", "\n", "#### Initial States $\\rightleftharpoons$ Intermediate States $\\rightleftharpoons$ Final States\n", "\n", "Here $\\rightleftharpoons$ denote combinatorial binding to form the different complexes in the PolymerConformation. All Excluded States found during enumeration are skipped. If no initial_states are given, the CombinatorialConformation defaults to the unbound Polymer inside the PolymerConformation in the Final States. If no intermediate states are given, initial states convert directly to final states.\n", "\n", "Note that parameters for transitions between states can be stored under particular IDs using the state_part_ids {species:id} keyword. If None, the str(s0)-str(sf) is the default part_id for a transition between s0 and sf.\n", "\n", "First, we consider a simple example to produce the PolymerConformation pc2 in the previous cell." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Species(N = 5) = {\n", " conformation[ordered_polymer_A_A_B_C_] (@ 0), \n", " conformation[_ordered_polymer_A_A_B_C__p0l1p0l3n_complex_A_C_S_] (@ 0), \n", " conformation[_ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B__p0l1p0l3n_complex_A_C_S_] (@ 0), \n", " conformation[_ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B_] (@ 0), \n", " S (@ 0), \n", "}\n", "\n", "Reactions (4) = [\n", "0. conformation[ordered_polymer_A_A_B_C_] <--> conformation[_ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B_]\n", " Kf=k_forward * ordered_polymer_A_A_B_C_\n", " Kr=k_reverse * conformation__ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B__\n", " k_forward=1.0\n", " found_key=(mech=None, partid=None, name=kf).\n", " search_key=(mech=one_step_conformation_change, partid=ordered_polymer_A_A_B_C_-conformation__ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B__, name=kf).\n", " k_reverse=1.0\n", " found_key=(mech=None, partid=None, name=kr).\n", " search_key=(mech=one_step_conformation_change, partid=ordered_polymer_A_A_B_C_-conformation__ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B__, name=kr).\n", "\n", "1. conformation[_ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B_]+S <--> conformation[_ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B__p0l1p0l3n_complex_A_C_S_]\n", " Kf=k_forward * conformation__ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B__ * S\n", " Kr=k_reverse * conformation__ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B__p0l1p0l3n_complex_A_C_S__\n", " k_forward=1.0\n", " found_key=(mech=None, partid=None, name=kf).\n", " search_key=(mech=one_step_conformation_change, partid=conformation__ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B__-conformation__ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B__p0l1p0l3n_complex_A_C_S__, name=kf).\n", " k_reverse=1.0\n", " found_key=(mech=None, partid=None, name=kr).\n", " search_key=(mech=one_step_conformation_change, partid=conformation__ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B__-conformation__ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B__p0l1p0l3n_complex_A_C_S__, name=kr).\n", "\n", "2. conformation[ordered_polymer_A_A_B_C_]+S <--> conformation[_ordered_polymer_A_A_B_C__p0l1p0l3n_complex_A_C_S_]\n", " Kf=k_forward * ordered_polymer_A_A_B_C_ * S\n", " Kr=k_reverse * conformation__ordered_polymer_A_A_B_C__p0l1p0l3n_complex_A_C_S__\n", " k_forward=1.0\n", " found_key=(mech=None, partid=None, name=kf).\n", " search_key=(mech=one_step_conformation_change, partid=ordered_polymer_A_A_B_C_-conformation__ordered_polymer_A_A_B_C__p0l1p0l3n_complex_A_C_S__, name=kf).\n", " k_reverse=1.0\n", " found_key=(mech=None, partid=None, name=kr).\n", " search_key=(mech=one_step_conformation_change, partid=ordered_polymer_A_A_B_C_-conformation__ordered_polymer_A_A_B_C__p0l1p0l3n_complex_A_C_S__, name=kr).\n", "\n", "3. conformation[_ordered_polymer_A_A_B_C__p0l1p0l3n_complex_A_C_S_] <--> conformation[_ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B__p0l1p0l3n_complex_A_C_S_]\n", " Kf=k_forward * conformation__ordered_polymer_A_A_B_C__p0l1p0l3n_complex_A_C_S__\n", " Kr=k_reverse * conformation__ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B__p0l1p0l3n_complex_A_C_S__\n", " k_forward=1.0\n", " found_key=(mech=None, partid=None, name=kf).\n", " search_key=(mech=one_step_conformation_change, partid=conformation__ordered_polymer_A_A_B_C__p0l1p0l3n_complex_A_C_S__-conformation__ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B__p0l1p0l3n_complex_A_C_S__, name=kf).\n", " k_reverse=1.0\n", " found_key=(mech=None, partid=None, name=kr).\n", " search_key=(mech=one_step_conformation_change, partid=conformation__ordered_polymer_A_A_B_C__p0l1p0l3n_complex_A_C_S__-conformation__ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B__p0l1p0l3n_complex_A_C_S__, name=kr).\n", "\n", "]\n" ] } ], "source": [ "from biocrnpyler.core import Mixture\n", "from biocrnpyler.components import CombinatorialConformation\n", "\n", "cc = CombinatorialConformation(final_states = [pc2])\n", "\n", "params = {\"kf\":1.0, \"kr\":1.0}\n", "M = Mixture(components = [cc], parameters = params)\n", "\n", "CRN = M.compile_crn()\n", "\n", "print(CRN.pretty_print())" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Example 2 (continued)\n", "\n", "The enumerated reactions can be restricted by choosing a set of intermediate states, initial states, and excluded states." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "CRN starting at a different initial state:\n", " Species(N = 3) = {\n", " conformation[_ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B__p0l1p0l3n_complex_A_C_S_] (@ 0), \n", " conformation[_ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B_] (@ 0), \n", " S (@ 0), \n", "}\n", "\n", "Reactions (1) = [\n", "0. conformation[_ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B_]+S <--> conformation[_ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B__p0l1p0l3n_complex_A_C_S_]\n", " Kf=k_forward * conformation__ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B__ * S\n", " Kr=k_reverse * conformation__ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B__p0l1p0l3n_complex_A_C_S__\n", " k_forward=1.0\n", " found_key=(mech=None, partid=None, name=kf).\n", " search_key=(mech=one_step_conformation_change, partid=conformation__ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B__-conformation__ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B__p0l1p0l3n_complex_A_C_S__, name=kf).\n", " k_reverse=1.0\n", " found_key=(mech=None, partid=None, name=kr).\n", " search_key=(mech=one_step_conformation_change, partid=conformation__ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B__-conformation__ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B__p0l1p0l3n_complex_A_C_S__, name=kr).\n", "\n", "]\n", "CRN with contrained intermediate states:\n", " Species(N = 4) = {\n", " conformation[ordered_polymer_A_A_B_C_] (@ 0), \n", " conformation[_ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B__p0l1p0l3n_complex_A_C_S_] (@ 0), \n", " conformation[_ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B_] (@ 0), \n", " S (@ 0), \n", "}\n", "\n", "Reactions (2) = [\n", "0. conformation[ordered_polymer_A_A_B_C_] <--> conformation[_ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B_]\n", " Kf=k_forward * ordered_polymer_A_A_B_C_\n", " Kr=k_reverse * conformation__ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B__\n", " k_forward=1.0\n", " found_key=(mech=None, partid=None, name=kf).\n", " search_key=(mech=one_step_conformation_change, partid=ordered_polymer_A_A_B_C_-conformation__ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B__, name=kf).\n", " k_reverse=1.0\n", " found_key=(mech=None, partid=None, name=kr).\n", " search_key=(mech=one_step_conformation_change, partid=ordered_polymer_A_A_B_C_-conformation__ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B__, name=kr).\n", "\n", "1. conformation[_ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B_]+S <--> conformation[_ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B__p0l1p0l3n_complex_A_C_S_]\n", " Kf=k_forward * conformation__ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B__ * S\n", " Kr=k_reverse * conformation__ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B__p0l1p0l3n_complex_A_C_S__\n", " k_forward=1.0\n", " found_key=(mech=None, partid=None, name=kf).\n", " search_key=(mech=one_step_conformation_change, partid=conformation__ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B__-conformation__ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B__p0l1p0l3n_complex_A_C_S__, name=kf).\n", " k_reverse=1.0\n", " found_key=(mech=None, partid=None, name=kr).\n", " search_key=(mech=one_step_conformation_change, partid=conformation__ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B__-conformation__ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B__p0l1p0l3n_complex_A_C_S__, name=kr).\n", "\n", "]\n", "CRN starting at a different initial state:\n", " Species(N = 4) = {\n", " conformation[ordered_polymer_A_A_B_C_] (@ 0), \n", " conformation[_ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B__p0l1p0l3n_complex_A_C_S_] (@ 0), \n", " conformation[_ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B_] (@ 0), \n", " S (@ 0), \n", "}\n", "\n", "Reactions (2) = [\n", "0. conformation[ordered_polymer_A_A_B_C_] <--> conformation[_ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B_]\n", " Kf=k_forward * ordered_polymer_A_A_B_C_\n", " Kr=k_reverse * conformation__ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B__\n", " k_forward=1.0\n", " found_key=(mech=None, partid=None, name=kf).\n", " search_key=(mech=one_step_conformation_change, partid=ordered_polymer_A_A_B_C_-conformation__ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B__, name=kf).\n", " k_reverse=1.0\n", " found_key=(mech=None, partid=None, name=kr).\n", " search_key=(mech=one_step_conformation_change, partid=ordered_polymer_A_A_B_C_-conformation__ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B__, name=kr).\n", "\n", "1. conformation[_ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B_]+S <--> conformation[_ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B__p0l1p0l3n_complex_A_C_S_]\n", " Kf=k_forward * conformation__ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B__ * S\n", " Kr=k_reverse * conformation__ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B__p0l1p0l3n_complex_A_C_S__\n", " k_forward=1.0\n", " found_key=(mech=None, partid=None, name=kf).\n", " search_key=(mech=one_step_conformation_change, partid=conformation__ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B__-conformation__ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B__p0l1p0l3n_complex_A_C_S__, name=kf).\n", " k_reverse=1.0\n", " found_key=(mech=None, partid=None, name=kr).\n", " search_key=(mech=one_step_conformation_change, partid=conformation__ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B__-conformation__ordered_polymer_A_A_B_C__p0l0p0l2_complex_A_B__p0l1p0l3n_complex_A_C_S__, name=kr).\n", "\n", "]\n" ] } ], "source": [ "params = {\"kf\":1.0, \"kr\":1.0}\n", "\n", "#Use a different initial state\n", "cc1 = CombinatorialConformation(initial_states = [pc1], final_states = [pc2])\n", "M1 = Mixture(components = [cc1], parameters = params)\n", "CRN1 = M1.compile_crn()\n", "print(\"CRN starting at a different initial state:\\n\", CRN1.pretty_print())\n", "\n", "#Use default initial state but contrain the intermediate states\n", "cc2 = CombinatorialConformation(intermediate_states = [pc1], final_states = [pc2])\n", "M2 = Mixture(components = [cc2], parameters = params)\n", "CRN2 = M2.compile_crn()\n", "print(\"CRN with contrained intermediate states:\\n\", CRN2.pretty_print())\n", "\n", "#Exclude a particular state\n", "cc3 = CombinatorialConformation(excluded_states = [pc1], final_states = [pc2])\n", "M3 = Mixture(components = [cc3], parameters = params)\n", "CRN3 = M2.compile_crn()\n", "print(\"CRN starting at a different initial state:\\n\", CRN3.pretty_print())" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Example 3: CombinatorialConformationPromoter\n", "\n", "The CombinatorialConformationPromoter is a combination of Promoter and CombinatorialConformation that can be used to model transcription. In this example, we build a simple model of a piece of DNA which can fold into two different conformations with folding mediated by a transcription factor F. This model has two sites on the piece of DNA, an A site and a B site. The transcription factor F must first bind to the B site before allowing a loop to form between the A site and B site.\n", "\n", "Two variations of this model will be examined, one in which the folded states are transcriptionally activated and the other in which the folded states are transcriptionally repressed. " ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "This model produces 4 transcription reactions, one for each state in the promoter_states list.\n", "Additionally, there are 8 total different PolymerConformations with binding reactions enumerated between them.\n", "Species(N = 12) = {\n", " conformation[ordered_polymer_B_A_B_] (@ 0), \n", " conformation[_ordered_polymer_B_A_B__p0l2n_complex_B_F__p0l1p0l0n_complex_A_B_F_] (@ 0), \n", " conformation[_ordered_polymer_B_A_B__p0l2n_complex_B_F__p0l0n_complex_B_F_] (@ 0), \n", " conformation[_ordered_polymer_B_A_B__p0l2n_complex_B_F_] (@ 0), \n", " conformation[_ordered_polymer_B_A_B__p0l1p0l2n_complex_A_B_F_] (@ 0), \n", " conformation[_ordered_polymer_B_A_B__p0l1p0l0n_complex_A_B_F_] (@ 0), \n", " conformation[_ordered_polymer_B_A_B__p0l0n_complex_B_F__p0l2n_complex_B_F_] (@ 0), \n", " conformation[_ordered_polymer_B_A_B__p0l0n_complex_B_F__p0l1p0l2n_complex_A_B_F_] (@ 0), \n", " conformation[_ordered_polymer_B_A_B__p0l0n_complex_B_F_] (@ 0), \n", " protein[X] (@ 0), \n", " rna[X] (@ 0), \n", " F (@ 0), \n", "}\n", "\n", "Reactions (17) = [\n", "0. conformation[_ordered_polymer_B_A_B__p0l1p0l2n_complex_A_B_F_] --> conformation[_ordered_polymer_B_A_B__p0l1p0l2n_complex_A_B_F_]+rna[X]\n", "1. conformation[_ordered_polymer_B_A_B__p0l1p0l0n_complex_A_B_F_] --> conformation[_ordered_polymer_B_A_B__p0l1p0l0n_complex_A_B_F_]+rna[X]\n", "2. conformation[_ordered_polymer_B_A_B__p0l2n_complex_B_F__p0l1p0l0n_complex_A_B_F_] --> conformation[_ordered_polymer_B_A_B__p0l2n_complex_B_F__p0l1p0l0n_complex_A_B_F_]+rna[X]\n", "3. conformation[_ordered_polymer_B_A_B__p0l0n_complex_B_F__p0l1p0l2n_complex_A_B_F_] --> conformation[_ordered_polymer_B_A_B__p0l0n_complex_B_F__p0l1p0l2n_complex_A_B_F_]+rna[X]\n", "4. conformation[ordered_polymer_B_A_B_]+F <--> conformation[_ordered_polymer_B_A_B__p0l0n_complex_B_F_]\n", "5. conformation[ordered_polymer_B_A_B_]+F <--> conformation[_ordered_polymer_B_A_B__p0l2n_complex_B_F_]\n", "6. conformation[_ordered_polymer_B_A_B__p0l0n_complex_B_F_]+F <--> conformation[_ordered_polymer_B_A_B__p0l2n_complex_B_F__p0l0n_complex_B_F_]\n", "7. conformation[_ordered_polymer_B_A_B__p0l2n_complex_B_F__p0l0n_complex_B_F_] <--> conformation[_ordered_polymer_B_A_B__p0l1p0l0n_complex_A_B_F_]\n", "8. conformation[_ordered_polymer_B_A_B__p0l0n_complex_B_F_] <--> conformation[_ordered_polymer_B_A_B__p0l1p0l0n_complex_A_B_F_]\n", "9. conformation[_ordered_polymer_B_A_B__p0l1p0l0n_complex_A_B_F_]+F <--> conformation[_ordered_polymer_B_A_B__p0l2n_complex_B_F__p0l1p0l0n_complex_A_B_F_]\n", "10. conformation[_ordered_polymer_B_A_B__p0l0n_complex_B_F_]+F <--> conformation[_ordered_polymer_B_A_B__p0l0n_complex_B_F__p0l1p0l2n_complex_A_B_F_]\n", "11. conformation[_ordered_polymer_B_A_B__p0l2n_complex_B_F_]+F <--> conformation[_ordered_polymer_B_A_B__p0l2n_complex_B_F__p0l1p0l0n_complex_A_B_F_]\n", "12. conformation[_ordered_polymer_B_A_B__p0l2n_complex_B_F_]+F <--> conformation[_ordered_polymer_B_A_B__p0l0n_complex_B_F__p0l2n_complex_B_F_]\n", "13. conformation[_ordered_polymer_B_A_B__p0l0n_complex_B_F__p0l2n_complex_B_F_] <--> conformation[_ordered_polymer_B_A_B__p0l1p0l2n_complex_A_B_F_]\n", "14. conformation[_ordered_polymer_B_A_B__p0l2n_complex_B_F_] <--> conformation[_ordered_polymer_B_A_B__p0l1p0l2n_complex_A_B_F_]\n", "15. conformation[_ordered_polymer_B_A_B__p0l1p0l2n_complex_A_B_F_]+F <--> conformation[_ordered_polymer_B_A_B__p0l0n_complex_B_F__p0l1p0l2n_complex_A_B_F_]\n", "16. rna[X] --> rna[X]+protein[X]\n", "]\n" ] } ], "source": [ "from biocrnpyler.core import Mixture\n", "from biocrnpyler.components import CombinatorialConformationPromoter, DNAassembly\n", "from biocrnpyler.mechanisms import SimpleTranscription, SimpleTranslation\n", "\n", "A, B, F = Species(\"A\"), Species(\"B\"), Species(\"F\")\n", "\n", "#Operon without anything bound\n", "O = PolymerConformation(polymer = [B, A, B])\n", "#F bound to the first B site\n", "OF0 = Complex([O.polymers[0][0], F]).parent\n", "#F bound to the second B site\n", "OF1 = Complex([O.polymers[0][2], F]).parent\n", "#F Bound to both sites\n", "OF2 = Complex([OF1.polymers[0][2], F]).parent\n", "\n", "#Looped Conformations\n", "L0 = Complex([O.polymers[0][0], O.polymers[0][1], F]).parent\n", "L1 = Complex([O.polymers[0][2], O.polymers[0][1], F]).parent\n", "\n", "#Loop between B0 and A with all sites occuped by F\n", "L0F1 = Complex([OF1.polymers[0][0], OF1.polymers[0][1], F]).parent\n", "#Loop between B1 and A with all sites occuped by F\n", "L1F0 = Complex([OF0.polymers[0][2], OF0.polymers[0][1], F]).parent\n", "\n", "#Create a CombinatorialConformationPromoter\n", "CCP = CombinatorialConformationPromoter(name = \"CCP\", \n", " intermediate_states = [OF0, OF1], #F must first bind to B sites\n", " final_states = [OF2, L0F1, L1F0], #A list of the saturated (most bound) states\n", " promoter_states = [L0F1, L1F0, L0, L1], #these states will be transcribed\n", " promoter_states_on = True, #toggling this will switch wether or not promoter_states are transcribed\n", " promoter_location = 1 #the location a polymerase may bind (if this is included in the transcription mechanism)\n", " )\n", "#Create a DNAassembly\n", "A = DNAassembly(name = \"X\", dna = O, promoter = CCP, rbs = \"rbs\", protein = \"X\")\n", "\n", "mechanisms = [SimpleTranscription(), SimpleTranslation()]\n", "\n", "M = Mixture(components = [A], mechanisms = mechanisms, parameters = {\"kf\":1.0, \"kr\":1.0, \"ktx\":1.0, \"ktl\":1.0})\n", "\n", "CRN = M.compile_crn()\n", "\n", "print(\"This model produces 4 transcription reactions, one for each state in the promoter_states list.\")\n", "print(\"Additionally, there are 8 total different PolymerConformations with binding reactions enumerated between them.\")\n", "print(CRN.pretty_print(show_rates = False))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### By toggling promoter_states_on = False, the looped promoters will now become repressed with every other state transcribable by default." ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "This model produces 4 transcription reactions, one for each state in the promoter_states list.\n", "Additionally, there are 8 total different PolymerConformations with binding reactions enumerated between them.\n", "Notice that the transcribed conformations are all different from the previous example.\n", "Species(N = 12) = {\n", " conformation[ordered_polymer_B_A_B_] (@ 0), \n", " conformation[_ordered_polymer_B_A_B__p0l2n_complex_B_F__p0l1p0l0n_complex_A_B_F_] (@ 0), \n", " conformation[_ordered_polymer_B_A_B__p0l2n_complex_B_F__p0l0n_complex_B_F_] (@ 0), \n", " conformation[_ordered_polymer_B_A_B__p0l2n_complex_B_F_] (@ 0), \n", " conformation[_ordered_polymer_B_A_B__p0l1p0l2n_complex_A_B_F_] (@ 0), \n", " conformation[_ordered_polymer_B_A_B__p0l1p0l0n_complex_A_B_F_] (@ 0), \n", " conformation[_ordered_polymer_B_A_B__p0l0n_complex_B_F__p0l2n_complex_B_F_] (@ 0), \n", " conformation[_ordered_polymer_B_A_B__p0l0n_complex_B_F__p0l1p0l2n_complex_A_B_F_] (@ 0), \n", " conformation[_ordered_polymer_B_A_B__p0l0n_complex_B_F_] (@ 0), \n", " protein[X] (@ 0), \n", " rna[X] (@ 0), \n", " F (@ 0), \n", "}\n", "\n", "Reactions (18) = [\n", "0. conformation[_ordered_polymer_B_A_B__p0l2n_complex_B_F__p0l0n_complex_B_F_] --> conformation[_ordered_polymer_B_A_B__p0l2n_complex_B_F__p0l0n_complex_B_F_]+rna[X]\n", "1. conformation[ordered_polymer_B_A_B_] --> conformation[ordered_polymer_B_A_B_]+rna[X]\n", "2. conformation[_ordered_polymer_B_A_B__p0l0n_complex_B_F_] --> conformation[_ordered_polymer_B_A_B__p0l0n_complex_B_F_]+rna[X]\n", "3. conformation[_ordered_polymer_B_A_B__p0l2n_complex_B_F_] --> conformation[_ordered_polymer_B_A_B__p0l2n_complex_B_F_]+rna[X]\n", "4. conformation[_ordered_polymer_B_A_B__p0l0n_complex_B_F__p0l2n_complex_B_F_] --> conformation[_ordered_polymer_B_A_B__p0l0n_complex_B_F__p0l2n_complex_B_F_]+rna[X]\n", "5. conformation[ordered_polymer_B_A_B_]+F <--> conformation[_ordered_polymer_B_A_B__p0l0n_complex_B_F_]\n", "6. conformation[ordered_polymer_B_A_B_]+F <--> conformation[_ordered_polymer_B_A_B__p0l2n_complex_B_F_]\n", "7. conformation[_ordered_polymer_B_A_B__p0l0n_complex_B_F_]+F <--> conformation[_ordered_polymer_B_A_B__p0l2n_complex_B_F__p0l0n_complex_B_F_]\n", "8. conformation[_ordered_polymer_B_A_B__p0l2n_complex_B_F__p0l0n_complex_B_F_] <--> conformation[_ordered_polymer_B_A_B__p0l1p0l0n_complex_A_B_F_]\n", "9. conformation[_ordered_polymer_B_A_B__p0l0n_complex_B_F_] <--> conformation[_ordered_polymer_B_A_B__p0l1p0l0n_complex_A_B_F_]\n", "10. conformation[_ordered_polymer_B_A_B__p0l1p0l0n_complex_A_B_F_]+F <--> conformation[_ordered_polymer_B_A_B__p0l2n_complex_B_F__p0l1p0l0n_complex_A_B_F_]\n", "11. conformation[_ordered_polymer_B_A_B__p0l0n_complex_B_F_]+F <--> conformation[_ordered_polymer_B_A_B__p0l0n_complex_B_F__p0l1p0l2n_complex_A_B_F_]\n", "12. conformation[_ordered_polymer_B_A_B__p0l2n_complex_B_F_]+F <--> conformation[_ordered_polymer_B_A_B__p0l2n_complex_B_F__p0l1p0l0n_complex_A_B_F_]\n", "13. conformation[_ordered_polymer_B_A_B__p0l2n_complex_B_F_]+F <--> conformation[_ordered_polymer_B_A_B__p0l0n_complex_B_F__p0l2n_complex_B_F_]\n", "14. conformation[_ordered_polymer_B_A_B__p0l0n_complex_B_F__p0l2n_complex_B_F_] <--> conformation[_ordered_polymer_B_A_B__p0l1p0l2n_complex_A_B_F_]\n", "15. conformation[_ordered_polymer_B_A_B__p0l2n_complex_B_F_] <--> conformation[_ordered_polymer_B_A_B__p0l1p0l2n_complex_A_B_F_]\n", "16. conformation[_ordered_polymer_B_A_B__p0l1p0l2n_complex_A_B_F_]+F <--> conformation[_ordered_polymer_B_A_B__p0l0n_complex_B_F__p0l1p0l2n_complex_A_B_F_]\n", "17. rna[X] --> rna[X]+protein[X]\n", "]\n" ] } ], "source": [ "#Create a CombinatorialConformationPromoter\n", "CCP = CombinatorialConformationPromoter(name = \"CCP\", \n", " intermediate_states = [OF0, OF1], #F must first bind to B sites\n", " final_states = [OF2, L0F1, L1F0], #A list of the saturated (most bound) states\n", " promoter_states = [L0F1, L1F0, L0, L1], #these states will be transcribed\n", " promoter_states_on = False, #toggling this will switch wether or not promoter_states are transcribed\n", " promoter_location = 1 #the location a polymerase may bind (if this is included in the transcription mechanism)\n", " )\n", "#Create a DNAassembly\n", "A = DNAassembly(name = \"X\", dna = O, promoter = CCP, rbs = \"rbs\", protein = \"X\")\n", "\n", "mechanisms = [SimpleTranscription(), SimpleTranslation()]\n", "\n", "M = Mixture(components = [A], mechanisms = mechanisms, parameters = {\"kf\":1.0, \"kr\":1.0, \"ktx\":1.0, \"ktl\":1.0})\n", "\n", "CRN = M.compile_crn()\n", "\n", "print(\"This model produces 4 transcription reactions, one for each state in the promoter_states list.\")\n", "print(\"Additionally, there are 8 total different PolymerConformations with binding reactions enumerated between them.\")\n", "print(\"Notice that the transcribed conformations are all different from the previous example.\")\n", "print(CRN.pretty_print(show_rates = False))" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "# End" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.3" } }, "nbformat": 4, "nbformat_minor": 4 }